﻿using System;

namespace Sample
{
    public class AttackStrategySegment
    {
        private readonly CombatResultsTable combatResultsTable;
        private readonly DiceRoll diceRoll;

        public AttackStrategySegment(DiceRoll diceRoll, CombatResultsTable combatResultsTable)
        {
            this.diceRoll = diceRoll;
            this.combatResultsTable = combatResultsTable;
        }

        public CombatResult Attack(Stack attacker, Stack defender)
        {
            Int32 av = attacker.CalculateAttack();
            Int32 dv = defender.CalculateDefense();

            CombatRatio ratio = new CombatRatio(av, dv);

            Int32 diceRollValue = diceRoll.RollValue();

            CombatResult result = this.combatResultsTable.DetermineResult(diceRollValue, ratio);
            return result;
        }
    }
}
